home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / FROMUTS / UNIXLIB37B / src / c / stricmp < prev    next >
Text File  |  1991-09-23  |  1KB  |  59 lines

  1. #ifdef __STDC__
  2. static char sccs_id[] = "@(#) stricmp.c 1.0 "__DATE__" HJR";
  3. #else
  4. static char sccs_id[] = "@(#) stricmp.c 1.0 23/9/91 HJR";
  5. #endif
  6.  
  7. /* stricmp.c (c) Copyright 1990 H.Rogers */
  8.  
  9. #ifndef __STDC__
  10. #include "sys/types.h"
  11. #endif
  12. #include <string.h>
  13. #include <ctype.h>
  14.  
  15. #ifdef __STDC__
  16. int stricmp(register const char *s1,register const char *s2)
  17. #else
  18. int stricmp(s1,s2)
  19. register const char *s1;
  20. register const char *s2;
  21. #endif
  22. {
  23. register int i,j;
  24.  
  25. do
  26.   {
  27.   i = *s1++,j = *s2++;
  28.   i = isupper(i) ? _tolower(i) : i;
  29.   j = isupper(j) ? _tolower(j) : j;
  30.   }
  31. while (i && i == j);
  32.  
  33. return(i - j);
  34. }
  35.  
  36. #ifdef __STDC__
  37. int strnicmp(register const char *s1,register const char *s2,register size_t n)
  38. #else
  39. int strnicmp(s1,s2,n)
  40. register const char *s1;
  41. register const char *s2;
  42. register size_t n;
  43. #endif
  44. {
  45. register int i,j;
  46.  
  47. if (!n) return(0);
  48.  
  49. do
  50.   {
  51.   i = *s1++,j = *s2++;
  52.   i = isupper(i) ? _tolower(i) : i;
  53.   j = isupper(j) ? _tolower(j) : j;
  54.   }
  55. while (i && i == j && --n);
  56.  
  57. return(i - j);
  58. }
  59.